﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class per_integral_detail : MpageBase
{
    protected int i = ReadRequest.RequestInt("i"); 
    protected List<Model.IntegralExchange> userOrder = null;
    protected void Page_Load(object sender, EventArgs e)
    {
         
        bindData();
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bindData();
    }
    protected void timesl_SelectedIndexChanged(object sender, EventArgs e)
    {
        bindData();
    }
    protected void bindData()
    {
        PagedDataSource pds = new PagedDataSource();
        int times = int.Parse(this.timesl.SelectedValue.ToString());
        int type = int.Parse(this.typesl.SelectedValue.ToString());
        string where = "";
        if (times == 0)
        {
            where = " and DateDiff(dd,Addtime,getdate())=0";
        }
        else if (times == 1)
        {
            where = " and datediff(week,Addtime,getdate())=0";
        }
        else if (times == 2)
        {
            where = " and datediff(month,Addtime,getdate())=0 ";
        }
        else if (times == 3)
        {
            where = " and datediff(Month,Addtime,getdate()) <=3 and datediff(Month,Addtime,getdate()) >=0";
        }
        else if (times == 4)
        {
            where = " and datediff(Month,Addtime,getdate()) <=6 and datediff(Month,Addtime,getdate()) >=0";
        }
        else
        {
            where = "";
        }  
        string sql = "UserId=" + loginUserInfo.Id + " and Type=" + type + " " + where;
        int totalCount = 0;
        userOrder = BLL.IntegralExchange.GetPageListBysql(this.AspNetPager1.CurrentPageIndex - 1, this.AspNetPager1.PageSize, sql, out totalCount);
        if (userOrder != null && userOrder.Count > 0)
        {
            AspNetPager1.Visible = true;
            AspNetPager1.RecordCount = totalCount;
            pds.AllowPaging = true;
            pds.PageSize = AspNetPager1.PageSize;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;

        }
        else
        {
            AspNetPager1.Visible = false;
        }
    }
    protected void typesl_SelectedIndexChanged(object sender, EventArgs e)
    {
        bindData();
    }
}